package com.qf.service.impl;

import com.qf.mapper.OwnerMapper;
import com.qf.mapper.RoomMapper;
import com.qf.pojo.Owner;
import com.qf.pojo.Room;
import com.qf.service.OwnerService;
import com.qf.vo.OwnerVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zdl
 * @date 2025/2/15
 */
@Service
public class OwnerServiceImpl implements OwnerService {
    @Resource
    private OwnerMapper ownerMapper;
    @Resource
    private RoomMapper roomMapper;
    @Override
    public List<OwnerVo> findAllOwnerWithRoomWithBuildingByBuildingNameOrOwenerName(String buildingName, String ownerName) {
        return ownerMapper.selectAllOwnerWithRoomWithBuildingByBuildingNameOrOwenerName(buildingName,ownerName);
    }

    @Override
    public int insertOwner(Owner owner) {
        List<Room> rooms = roomMapper.allUseRoom();
        for (Room room : rooms) {
            owner.setRid(room.getRid());
            //ownerMapper.insertOwner();
        }
        return 0;
    }

    @Override
    public int delOwnerByOid(int oid) {
        return ownerMapper.delOwnerByOid(oid);
    }
}
